package com.LC._343;

class Solution {
    public int integerBreak(int n) {
    //dp[i]表示 i被拆分后所得最大乘积
        int[] dp = new int[n+1];//下标越界
        //递推公式 dp[i] = d[i] + j*(i-j);
        dp[2] =1;
        for(int i = 0; i <=n;i++){
            for(int j = 2; j <i-1;j++){
                //dp的来源有两条
            dp[i] = Math.max(dp[i] ,Math.max(j*(i-j) , j*dp[i-j]));
            }
        }
        return dp[n];

    }

    public static void main(String[] args) {
        Solution s = new Solution();
        System.out.println(s.integerBreak(2));
    }
}